package com.jiazhong.discope;

import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Auther:shuXin
 */
public class TestUser {
    @Test
    public void test01() {
        /*ApplicationContext ac = new ClassPathXmlApplicationContext("bean-discope.xml");
//       //默认创建对象为单实例对象，当改变值的时候才会成为创建多个实例对象，在配置文件xml中进行更改
        User user1 = ac.getBean("user", User.class);
        User user2 = ac.getBean("user", User.class);
        System.out.println(user1 == user2);*/

        ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("bean-life.xml");
        User user = ac.getBean(User.class);
        System.out.println("生命周期：6、通过IOC容器获取bean并使用");
        System.out.println(user);
        ac.close();
    }
}
